{extend name="template/base" /}
{block name="nav"}{/block}
{block name="content"}
<div class="page-container">
    <form class="form form-horizontal" id="form" method="post" action="{:\\think\\Request::instance()->baseUrl()}">
        <input type="hidden" name="id" value="{$vo.id ?? ''}">


        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3"><span class="c-red">*</span>图片：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <input type="text" readonly class="input-text" value="{$vo.thumb ?? ''}" name="thumb" id="upload" placeholder="请点击后面的上传按钮" datatype="*" nullmsg="请填写图片url" style="width: 70%">
                <button type="button" class="btn btn-primary radius" onclick="layer_open('文件上传','{:\\think\\Url::build(\'Upload/index\', [\'id\' => \'upload\'])}')">上传</button>
                <a onclick="$(this).attr('href', 'http://{$Request.host}/public'+$('#upload').val())" type="button" class="btn btn-success radius" data-lightbox="preview">预览</a>
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>

        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3"><span class="c-red">*</span>轮播图详情：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <!--<p class="c-red">集成七牛上传，请在编辑器里上传图片 < 请配置自己的七牛帐号 (admin/extra/qiniu.php) ></p>-->
                <script id="editor" name="content" type="text/plain" style="height:400px">{if condition="isset($vo.content)"}{$vo.content|htmlspecialchars_decode=###}{/if}</script>
            </div>
            <div class="formControls col-xs-6 col-sm-6">
                <div id="markdown" class="mt-20"></div>
            </div>
        </div>
        {if condition="$Request.param.position == 'second'"}
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3"><span class="c-red">*</span>商品种类：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <input type="hidden" name="types_first_id" value="{$vo.types_first_id ?? ''}">
                <input type="hidden" name="types_second_id" value="{$vo.types_second_id ?? ''}">
                <input type="hidden" name="types_third_id" value="{$vo.types_third_id ?? ''}">
                <span class="dropDown"> <a class="dropDown_A" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">选择种类</a>
                    <ul class="dropDown-menu menu radius box-shadow">
                        {volist name="typeTree" id="first" empty="请先创建商品种类"}
                        <li><a href="javascript:;">{$first.name}</a>
                            {if condition="!empty($first._child)"}
                            <ul class="dropDown-menu menu radius box-shadow">

                                {volist name="first._child" id="second"}
                                    <li>
                                        <a href="javascript:;">{$second.name}</a>
                                        {if condition="!empty($second._child)"}
                                            <ul class="dropDown-menu menu radius box-shadow">
                                                {volist name="second._child" id="third"}
                                                <li><a href="javascript:selectType({$first.id},{$second.id},{$third.id},'{$first.name}/{$second.name}/{$third.name}');">{$third.name}</a></li>
                                                {/volist}
                                            </ul>
                                        {/if}
                                        </li>
                                {/volist}

                            </ul>
                            {/if}
                        </li>
                        {/volist}
                    </ul>
                </span>
                <input type="text" readonly class="input-text" value="{$vo.types_name?? ''}" id="sel-types" placeholder="请点击右边按钮选择" datatype="*" nullmsg="请选择分类" style="width: 70%">
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        {/if}
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3"><span class="c-red">*</span>状态：</label>
            <div class="formControls col-xs-6 col-sm-6 skin-minimal">
                <div class="radio-box">
                    <input type="radio" name="status" id="status-1" value="1" datatype="*" nullmsg="请选择状态">
                    <label for="status-1">启用</label>
                </div>
                <div class="radio-box">
                    <input type="radio" name="status" id="status-0" value="0">
                    <label for="status-0">禁用</label>
                </div>
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>

        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <button type="submit" class="btn btn-primary radius">&nbsp;&nbsp;提交&nbsp;&nbsp;</button>
                <button type="button" class="btn btn-default radius ml-20" onClick="layer_close();">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
            </div>
        </div>
    </form>
</div>
{/block}
{block name="script"}
<script type="text/javascript" src="__LIB__/Validform/5.3.2/Validform.min.js"></script>
<script src="__LIB__/lightbox2/js/lightbox.min.js"></script>
<script>
    function selectType(fid,sid,tid,str) {
        $('#sel-types').val(str);
        $('input[name=types_first_id]').val(fid);
        $('input[name=types_second_id]').val(sid);
        $('input[name=types_third_id]').val(tid);
    }

    $(function () {
        $("[name='status'][value='{$vo.status ?? '1'}']").attr("checked",true);

        $('.skin-minimal input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        });

        $("#form").Validform({
            tiptype:2,
            ajaxPost:true,
            showAllError:true,
            callback:function(ret){
                ajax_progress(ret);
            }
        });
    })

</script>

<script type="text/javascript" src="__LIB__/showdown/1.4.2/showdown.min.js"></script>
<script>window.UEDITOR_HOME_URL = '__LIB__/ueditor/1.4.3/'</script>
<script type="text/javascript" charset="utf-8" src="__LIB__/ueditor/1.4.3/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="__LIB__/ueditor/1.4.3/ueditor.all.min.js"> </script>
<script type="text/javascript" charset="utf-8" src="__LIB__/ueditor/1.4.3/lang/zh-cn/zh-cn.js"></script>
<script>

    $(function () {
        var ue = UE.getEditor('editor',{
            serverUrl:'{:\\think\\Url::build("Ueditor/index")}'
        });
        var converter = new showdown.Converter(),
            text      = $("#markdown_tpl").html();
        $("#markdown").html(converter.makeHtml(text));
    })
</script>
{literal}
<script type="text/plain" id="markdown_tpl">
</script>
{/literal}
<!--<link rel="stylesheet" type="text/css" media="screen" href="__LIB__/lightbox2/css/lightbox.css" />
<script type="text/javascript" src="__LIB__/lightbox2/js/lightbox.js"></script>-->
{/block}